#include <Def.h>
#include <qfile.h>
#include <QtXml/qdom.h>

QDomElement getDomElementImpl(const QString& xml)
{
    QFile xmlfile(xml);
	QDomDocument doc;
    bool open = xmlfile.open(QIODevice::ReadOnly | QFile::Text);
	if(!open)
		return doc.documentElement();
	QString err;
	int line,col;
    open = doc.setContent(&xmlfile,false,&err,&line,&col);
	xmlfile.close();
    return doc.documentElement();
}

QDomElement getDomElementImpl(QIODevice* device)
{
	QDomDocument doc;
	QString err;
	int line,col;
    bool open = doc.setContent(device,false,&err,&line,&col);
    return doc.documentElement();
}

QDomElement getDomElement(const QString& xml)
{
    QDomElement ele = getDomElementImpl(xml);
	if(ele.isNull())
		return getDomElementImpl(QString(":%1").arg(xml));
	return ele;
}